import {useAxios} from '@/hooks/web/useAxios'
import type {UserLoginType, UserType} from './types'

const request = useAxios()

//登录
export const loginApi = (data: UserLoginType) => {
    return request.post({
        url: '/auth/login',
        data
    })
}

//用户信息
export const getInfo = () => {
    return request.get({
        url: '/system/user/getInfo'
    })
}

//路由
export const getRouters = () => {
    return request.get({
        url: '/system/user/getRouters?type=TJ01'
    })
}

//退出登录
export const loginOutApi = () => {
    return request.delete({url: '/auth/logout'})
}

export const getUserListApi = ({params}: AxiosConfig) => {
    return request.get<{
        total: number
        list: UserType[]
    }>({url: '/user/list', params})
}

export const getAdminRoleApi = ({params}) => {
    return request.get<{
        list: AppCustomRouteRecordRaw[]
    }>({url: '/role/list', params})
}

export const getTestRoleApi = ({params}) => {
    return request.get<{
        list: string[]
    }>({url: '/role/list', params})
}
